package cn.com.dhcc.app.pub.core.consts;

import org.springframework.util.StringUtils;

import cn.com.dhcc.app.core.AppEnv.ParaGetTool;
import cn.com.dhcc.app.core.tag.CommonStaticCode.YESNO;

public class NodeInfoParam {

	//网络类型（2：外网）（1：内网）
	public static final String NODE_NET_TYPE = ParaGetTool.getPara("node.net.type");
	//行政区编码
	public static final String NODE_REGION_CODE = ParaGetTool.getPara("node.region.code");
	public static final String isManaagerNode = ParaGetTool.getPara("node.is_manager_node");
	public static final String hasGap = ParaGetTool.getPara("node.hasgap");
	public static final String isMaster = ParaGetTool.getPara("node.is_manager_node");
	
	public static final String NODE_NAME = ParaGetTool.getPara("nodeinfo.nodename");
	public static final String NODE_CODE = ParaGetTool.getPara("nodeinfo.nodecode");
	public static final String ADMIN_EMAIL = ParaGetTool.getPara("nodeinfo.adminemail");
	public static final String ADMIN_USERNAME = "admin";
	public static final String DEFAULT_ADMIN_PWD = "admin";

	public static final String currentNode = ParaGetTool.getPara("si.node");
	public static final String ROLE_DATAEXCH_MGR_FOR_NODE = "ROLE_DATAEXCH_MGR_FOR_NODE";
	public static final String SYNC_WSDL_SURFIX = "/ws/node_communicate_service?wsdl";
	public static final String DEFAULT_DEPINFO_ROOT_ID = "000000000000000";
	public static final String DEFAULT_USERINFO_PWD = "111111";
	//public static final String APP_SERVER_URL = UrlUtil.removeSlashAndBlack(ParaGetTool.getPara("app.server.url").toLowerCase());
	/**
	 * 本地IP
	 */
	public static String LOCAL_IP = AppConst.installIp;
	public static final String MWR_PROPERTIES_FILENAME = "mwr.properties";
	
	public static final String MWR_NODE_NAME = ParaGetTool.getParaFromProperties(MWR_PROPERTIES_FILENAME, "mwr.node.name");
	public static final String MWR_NODE_ADMIN_EMAIL = ParaGetTool.getParaFromProperties(MWR_PROPERTIES_FILENAME, "mwr.node.admin.email");
	//**水利部节点的相关信息---开始
	//行政区编码																													  
	public static final String MWR_NODEREGION_CODE = ParaGetTool.getParaFromProperties(MWR_PROPERTIES_FILENAME, "mwr.node.region.code");
	//**水利部节点父节点编码
	public static final String MWR_NODE_PID = "00000000000000000000000000000000";
	//根节点为水利部
	public static final String ROOT_NODEREGION_CODE = MWR_NODEREGION_CODE;

	/**
	 * 是否是中央节点
	 * @return
	 */
	public static boolean isMwr(){
		return StringUtils.hasText(NODE_REGION_CODE)&&NODE_REGION_CODE.trim().equalsIgnoreCase(ROOT_NODEREGION_CODE);
	}
	/**
	 * 是否是中央节点
	 * @return
	 */
	public static boolean hasGap(){
		return StringUtils.hasText(hasGap)&&hasGap.trim().equalsIgnoreCase(YESNO.YES.getStatus());
	}
	/**
	 * 是否是管理节点，每个行政区管理节点只能有一个
	 * @return
	 */
	public static boolean isManaagerNode(){
		return  StringUtils.hasText(isManaagerNode)&&isManaagerNode.trim().equalsIgnoreCase(YESNO.YES.getStatus());
	}
	/**
	 * 在集群的时候，需要制定一个为主节点
	 * @return
	 */
	public static boolean isMaster(){
		return  StringUtils.hasText(isMaster)&&isMaster.trim().equalsIgnoreCase(YESNO.YES.getStatus());
	}
	/**
	 * 是否与是外网
	 * @return
	 */
	public static boolean isInnerNode(){
		return  StringUtils.hasText(NODE_NET_TYPE)&&NODE_NET_TYPE.trim().equalsIgnoreCase(NET_TYPE.INNER.getCode());
	}
	/**
	 * 是否与是内网
	 * @return
	 */
	public static boolean isOuterNode(){
		return  StringUtils.hasText(NODE_NET_TYPE)&&NODE_NET_TYPE.trim().equalsIgnoreCase(NET_TYPE.EXTRA.getCode());
	}

	/**
	 * 网闸信息
	 * @author qiao
	 * @2014-11-14 @下午3:02:54
	 */
	public static class GAP_PARAM{
			public static final String IP = ParaGetTool.getPara("app.gap.ftp.ip");// FTP服务器地址
			public static final int Port =Integer.parseInt(ParaGetTool.getPara("app.gap.ftp.port"));// FTP服务器端口
			public static final String UserName = ParaGetTool.getPara("app.gap.ftp.username");// 登录FTP服务器账号
			public static final String Password = ParaGetTool.getPara("app.gap.ftp.password");// 登陆FTP服务器密码
			public static final String Home = ParaGetTool.getPara("app.gap.ftp.home")==null || "".equals(ParaGetTool.getPara("app.gap.ftp.home"))?"/":ParaGetTool.getPara("app.gap.ftp.home"); // 下载文件目录
			//public static final String Output = ParaGetTool.getPara("app.gap.ftp.input"); // 下载文件目录
	}
	public static enum NET_TYPE {
		EXTRA("2", "外网"), INNER("1", "内网");
		private String code;
		private String name;

		NET_TYPE(String code, String name) {
			this.code = code;
			this.name = name;
		}

		public String getCode() {
			return code;
		}

		public void setCode(String code) {
			this.code = code;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}
	}

	/**
	 * 节点类型
	 * 
	 * @author qiao
	 * @2014-7-30 @上午11:05:53
	 */
	public static enum NODE_TYPE {
		MWR("1", "水利部节点"), LIUYU("2", "流域节点"), PROVINCE("3", "省节点");
		private String code;
		private String name;

		NODE_TYPE(String code, String name) {
			this.code = code;
			this.name = name;
		}

		public String getCode() {
			return code;
		}

		public void setCode(String code) {
			this.code = code;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}
	}
}
